/*
 * @Author: Wangjun
 * @Date: 2023-08-03 09:51:03
 * @LastEditTime: 2023-09-06 10:31:23
 * @LastEditors: Wangjun
 * @Description:
 * @FilePath: \nodex\nodelogic\op_not_good_a.go
 * hnxr
 */
package nodelogic

import (
	"gitee.com/hnxr_1/nodex"
)

func init() {
	nodex.Reister(new(NGA))
}

// NGA Not good
type NGA struct {
	nodex.Node
	X  nodex.Double  `remark:"输入X"`
	NG nodex.Boolean `remark:"false:好;true坏"` //false 没有问题， true有问题 not good
	Y  nodex.Double  `remark:"输出Y,,out"`
}

func (m *NGA) GetModelID() int {
	return nodex.ModLogic
}
func (m *NGA) Init(mem *nodex.Memory) (err error) {
	m.Y.Bad = &m.Bad
	return
}

/**
 * @description:
 * @return {*}
 */
func (m *NGA) GetName() string {
	return "NGA"
}

func (m *NGA) RegData() []byte {
	return nodex.MakeRegData(m, "模拟量质量差", m.GetName(), "")
}

func (m *NGA) Calc() (err error) {
	if m.EnQ {
		if *m.X.Bad || *m.NG.Bad {
			m.Bad = true
			return //不计算
		}
	}

	m.Y.Value = m.X.Value
	m.Bad = m.NG.Value
	return
}
